#include <stdio.h>
#include <assert.h>

#include "singleton.h"

/*---------------------------------------------------------------------------*/

void test();

/*---------------------------------------------------------------------------*/

int main()
{
	test();
	printf("Tests OK!");
	return 0;
}

/*---------------------------------------------------------------------------*/

void test()
{
	// Singleton default value
	Singleton* s1 = Singleton::getInstance();
	assert( s1->get() == 0 );

	// Singleton set value
	Singleton* s2 = Singleton::getInstance();
	s2->set( 5 );
	assert( s2->get() == 5 );

	// Check several pointers
	assert( s1->get() == s2->get() );
	assert( Singleton::getInstance()->get() == Singleton::getInstance()->get() );

	// Several changes
	Singleton* s3 = Singleton::getInstance();
	s1->set( 6 );
	s2->set( 7 );
	assert( s3->get() == 7 );
}

/*---------------------------------------------------------------------------*/
